package service;

import entity.Luggage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lishunlin110
 * @version 1.0
 * @description: 服务层实现
 * @date 2021/9/19 16:22
 */
public class GiveResultServiceImpl implements GiveResultService{

    //将行李信息封装在 list链表中,根据计费方式的不同分为两种类型的list
    private Map<String,List<Luggage>> SaveLuggageInformation(String[] luggages){
        List<Luggage> specialBilledLuggage = new ArrayList<>();
        List<Luggage> luggageByWeight= new ArrayList<>();
        Map<String,List<Luggage>> luggageMap = new HashMap<>();
        for(String s:luggages){
            String[] parameters = s.split(",");
            String type =  parameters[4];
            //去除免费托运的特殊行李
            if(type.equals("Free")){continue;}
            double length = Double.parseDouble(parameters[0]);
            double width = Double.parseDouble(parameters[1]);
            double height = Double.parseDouble(parameters[2]);
            double weight = Double.parseDouble(parameters[3]);
            Luggage luggage = new Luggage(length,width,height,weight,type);
            if(type.equals("ordinary")||type.equals("SportsEquipment1")||type.equals("other1")){
                luggageByWeight.add(luggage);
            } else {
                specialBilledLuggage.add(luggage);
            }
        }
        luggageMap.put("specialBilledLuggage",specialBilledLuggage);
        luggageMap.put("luggageByWeight",luggageByWeight);
        return luggageMap;
    }

    //行李费用计算,在排除掉免费行李后
    private double countLuggageByWeight(List<Luggage> luggageList){

        return 0;
    }

    @Override
    public String giveResult(String[] luggages, String... parameter) {
        return null;
    }
}
